﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.CommunityToolkit.Extensions;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace KursachApp
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class CRUDNotesPage : ContentPage
    {
        public int userid;
        public CRUDNotesPage(int usid)
        {
            InitializeComponent();
            userid = usid;
            
        }

        private async void SaveFriend(object sender, EventArgs e)
        {
           
            var item = (Notes)BindingContext;
            if (!String.IsNullOrEmpty(item.Theme))
            {
                await App.Database.SaveItemAsync2(item);
            }
            await this.Navigation.PopAsync();
            await this.DisplayToastAsync("Успешно сохранено", 2000);
        }

        private async void DeleteFriend(object sender, EventArgs e)
        {
            var item = (Notes)BindingContext;
            await App.Database.DeleteItemAsync2(item);
            await this.Navigation.PopAsync();
            await this.DisplayToastAsync("Успешно удалено", 2000);
        }

        private async void Cancel(object sender, EventArgs e)
        {
            await this.Navigation.PopAsync();
        }

        private void OnLabelTapped(object sender, EventArgs e)
        {
            datetb.Text = DateTime.Now.ToString();
        }
    }
}